import { request } from "@/utils/http";
import requestTrademark from "@/utils/http/trademark"
import type { GetInfoResponse, LoginResponse,TrademarkInfoData } from "./model/userTypes";
import {TrademarkData} from "./model/userTypes"
// 登录
export const reqLogin = (username: string, password: string) => {
  // <any, string>的第一个类型为any即可，实际不会用上
  // 第二个类型是返回值数据中data的类型，根据接口文档填写
  return request.post<any, LoginResponse>("/admin/auth/index/login", {
    username,
    password,
  });
};

// 登出
export const reqLogout = () => {
  return request.post<any, null>("/admin/auth/index/logout");
};

// 查询用户信息
export const reqGetUserInfo = () => {
  return request.get<any, GetInfoResponse>("/admin/auth/index/info");
};

//获取品牌列表请求函数
export const reqTrademarkPageList = (page:number, limit:number)=>{
  return requestTrademark.get<any,TrademarkInfoData>(`/admin/product/baseTrademark/${page}/${limit}`)
}

 // POST /admin/product/baseTrademark/save
  // 新增BaseTrademark
  // PUT /admin/product/baseTrademark/update
  // 修改BaseTrademark
export const addOrUpdate = (trademark: TrademarkData)=> {
    if (trademark.id) {
      return requestTrademark.put<any, null>('/admin/product/baseTrademark/update',trademark)
    } else {
      return requestTrademark.post<any, null>('/admin/product/baseTrademark/save',trademark)
    }
}

//删除品牌
  export const removeTrademark =(id: number)=>{
    return requestTrademark.delete<any, null>(`/admin/product/baseTrademark/remove/${id}`)
  }
  

